package com.mflex.WHSmartWhouseAd.adapter;

import android.app.Activity;
import android.graphics.Color;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.mflex.WHSmartWhouseAd.R;
import com.mflex.WHSmartWhouseAd.model.MaterialDetailForSMTModel;
import com.mflex.WHSmartWhouseAd.model.MaterialDetailModel;
import com.xuexiang.xutil.common.StringUtils;

import java.util.List;

public class SMTMaterialOutStockTaskDetailAdapter extends BaseAdapter {
    List<MaterialDetailForSMTModel> items;
    Activity context;

    public SMTMaterialOutStockTaskDetailAdapter(Activity context, List<MaterialDetailForSMTModel> items) {
        this.context = context;
        this.items = items;
    }

    @Override
    public int getCount() {
        return items.size();
    }

    @Override
    public Object getItem(int position) {
        return items.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        MaterialDetailForSMTModel item = items.get(position);
        View view = convertView;
        view = context.getLayoutInflater().inflate(R.layout.item_material_outstock_task_detail_list, null);
        ((TextView) view.findViewById(R.id.txtPN)).setText(item.getMaterialPart());
        ((TextView) view.findViewById(R.id.txtLoc)).setText(item.getWHLocation());
        ((TextView) view.findViewById(R.id.txtVehicleNO)).setText(item.getVehicleNumber());
        ((TextView) view.findViewById(R.id.txtVehicleStatus)).setText(item.getVehicleStatus());
        ((TextView) view.findViewById(R.id.txtPanelQty)).setText(item.getPlateCount());
        ((TextView) view.findViewById(R.id.txtScanQty)).setText(item.getScannum());
        ((TextView) view.findViewById(R.id.txtQty)).setText(item.getQty());
        ((TextView) view.findViewById(R.id.txtEXPDate)).setText(item.getExpDate());

        if (StringUtils.equals("1",item.getFlag())) {
            ((LinearLayout) view.findViewById(R.id.txtList)).setBackgroundColor(Color.YELLOW);
        }
        if (StringUtils.equals("2",item.getFlag())) {
            ((LinearLayout) view.findViewById(R.id.txtList)).setBackgroundColor(Color.GREEN);
        }


        return view;
    }
}